#include "../logs/bitlog.h"
#include <unistd.h>

void testlog(const std::string name)
{
    // Log::Logger::ptr logger = Log::LoggerManager::getInstance().getLogger(name);
    
    LOG_INFO("%s","测试开始");

    // logger->DEBUG("%s","测试日志");
    // logger->INFO("%s","测试日志");
    // logger->WARN("%s","测试日志");
    // logger->FATAL("%s","测试日志");
    
    // size_t count = 0;
    // while(count < 50000)
    // {
    //     logger->FATAL("测试日志-%d",count++);
    // }

    LOG_DEBUG("%s","测试日志");
    LOG_INFO("%s","测试日志");
    LOG_WARN("%s","测试日志");
    LOG_ERROR("%s","测试日志");
    LOG_FATAL("%s","测试日志");
    
    size_t count = 0;
    while(count < 50000)
    {
        LOG_FATAL("测试日志-%d",count++);
    }

    LOG_INFO("%s","测试结束");
}

int main(int argc, char *argv[])
{
    std::unique_ptr<Log::LoggerBuild> builder(new Log::GlobalLoggerBuild());
    builder->BuildLoggerName("async_logger");
    builder->BuildLoggerType(Log::LoggerType::LOGGER_ASYNC);
    builder->BuildLogLevel(Log::LogLevel::Value::DEBUG);
    builder->BuildFormatter("[%d{%H:%M:%S}][%t][%p][%c][%f:%l] %m%n");
    builder->BuildLogSink<Log::FileSink>("./LogFile/async.log");
    builder->Build();

    testlog("async_logger");

    return 0;
}